473,434 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

using javascript with radio button to disable a text box - does not work in IE

Hi,
I am trying to use javascript, div tag and radio button to
disable/enable a text box. It works fine
in netscape and firefox, but in IE, the text box is not disabled when
the user checks the radio button.

Note that I am using two div statements. Any other solutions also
wellcome.

<html>
<title>Test</title>

<head>
<script type="text/javascript">

function checkButton(rName) {

collection = document.all[rName];
if (collection[1].checked)
{
//document.myform.abutton.disabled = true;
document.getElementById("durfixed").style.display= "block";
document.getElementById("nodurfixed").style.displa y="none";
}
else
{
document.getElementById("durfixed").style.display= "none";
document.getElementById("nodurfixed").style.displa y="block";
}

}
</script>
</head>

<body >
<h2>Radio Button Check</h2>

<form name=myform>
<fieldset style="width:100px">
<legend>Toggle</legend>
<INPUT type=radio name=milestone value="Beta1"
onChange="checkButton('milestone')">Beta 1<br>
<INPUT type=radio name=milestone checked value="Beta2"
onChange="checkButton('milestone')">Beta 2<br>
</fieldset>

<br>

<div id="durfixed" style="display:block;" >
<input type=text name=ename value="">
</div>
<div id="nodurfixed" style="display:none;" >
<input type=text name=noename readonly value="" style="background:
#cccccc" >
</div>
</body>
</form>
</html>
Thanks for the help
Siva

Aug 29 '06 #1
1 24721
s.********@gmail.com wrote:
Hi,
I am trying to use javascript, div tag and radio button to
disable/enable a text box. It works fine
in netscape and firefox, but in IE, the text box is not disabled when
the user checks the radio button.
First, the solution: change your onchange to onclick.

Second, why. Your function is working in IE too. The difference is
tha in IE, the onchange event fires when the control loses focus (which
is as per the W3C spec) whereas other browsers fire a radio button's
onchange essentially as an onclick.

By using onclick, you'll get consistent behaviour across browsers.
Note however that using reload, it is possible to have the state of the
text input out of sync with the radio button selection in some (most?)
browsers. onload you should either run checkButton() or reset the form
to a known state.
--
Rob

Aug 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Raghuram Banda | last post by:
Hi, Can any one help me, how to create a Radio button using DOM with default one option is selected Thanks in advance
1
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there...
1
by: john | last post by:
I have two different problems: 1. When the user has clicked on a button that is causing the browser to post back to the server, it could take a little while for the new page to show up. So in...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
9
by: Marc | last post by:
Okay, here's the problem - I have 3 radio buttons, and 11 check boxes (which are disabled by default). I have the javascript below which when the last radio button is clicked, enables the...
8
by: stefano | last post by:
HI, I have aproblem with XHTML radio button. <form name=" form"> <input name="radio" type="radio" onclick="return false" /> <input name="radio" type="radio" onclick="return false" /> <input...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
1
Frinavale
by: Frinavale | last post by:
Introduction I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.